package day.statistic;

import utility.time.ProcessTime;

import java.text.SimpleDateFormat;

/**
 * Created by lit on 2018/4/13.
 */
public class Main {
    public static void main(String[] args){

        String[] dayStatTime = getDayStatTime(args);
        ProcessStatTripLink pstl = new ProcessStatTripLink();
        pstl.processTripLink(dayStatTime);

        ProcessStatDay psd = new ProcessStatDay();
        psd.processStatDay(dayStatTime);

        ProcessStatDistOD psdo = new ProcessStatDistOD();
        psdo.processDistOD(dayStatTime);
    }

    /**
     * 获取日统计的日期，返回的是一个字符串数组，包含间隔一天的时间字符串，如['2018-04-16','2018-04-17'],那么处理的是16号这天的统计
     * @param args
     * @return
     */
    private static String[] getDayStatTime(String[] args){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        if(args != null && args.length > 0){
            String nextDay = ProcessTime.addDayTime(args[0],1);
            String[] result =  {args[0],nextDay};
            return result;
        }else{
            String currentDay = sdf.format(System.currentTimeMillis());
            String preDay = ProcessTime.addDayTime(currentDay,-1);
            String[] result = {preDay,currentDay};
            return result;
        }

    }


}
